/**
 * モーダルウィンドウのテスト
 * to compile : haxe -swf-version 9 -swf Modal.swf -main Modal Modal.hx
 *
 * 2009/01 IT Planning.
 */

import flash.display.Sprite;
import flash.events.Event;
import flash.events.MouseEvent;
import flash.events.KeyboardEvent;

class Background extends Sprite
{
	public function new ()
	{
		super();
		this.graphics.beginFill( 0xffffff );
		this.graphics.drawRect( 0, 0, 1000, 1000 );
		this.graphics.endFill();
	}
}

class ModalWindow extends Sprite
{
	public function new ()
	{
		super();
		this.graphics.beginFill( 0x0000ff );
		this.graphics.drawRect( 100, 100, 50, 50 );
		this.graphics.endFill();
	}
}

class Modal
{
	public static function main() : Void
	{
		var back = new Background();
		var mw = new ModalWindow();
		flash.Lib.current.addChild( back );
		flash.Lib.current.addChild( mw );
		back.addEventListener( MouseEvent.CLICK, function(e) { trace("background"); } );
		mw.addEventListener( MouseEvent.CLICK, function(e) { trace("modal window"); } );
		flash.Lib.current.addEventListener(
			MouseEvent.CLICK,
			function( e : Event ) {
				if( e.target == mw ) {
				} else {
					e.stopImmediatePropagation();
				}
			},
			true // capture段階でこのイベントハンドラを動かす。
		);
	}
}